package com.zzyl.config;

import com.aliyun.iot20180120.Client;
import com.aliyun.teaopenapi.models.Config;
import com.zzyl.properties.AliIoTConfigProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class IotClientConfig {

    @Autowired
    private AliIoTConfigProperties iotProp;

    @Bean //把当前方法的返回对象放入IOC容器
    public Client client() throws Exception {
        Config config = new Config();
        config.setRegionId(iotProp.getRegionId());
        config.setAccessKeyId(iotProp.getAccessKeyId());
        config.setAccessKeySecret(iotProp.getAccessKeySecret());
        return new Client(config);
    }
}
